# coding:utf-8

# 批量更改文件名(删除文件前缀或后缀)
import os

# 列出路径下的所有文件（绝对路径）
def listAllDir(dPath):
	dirL = os.listdir(dPath)
	dirAbsPath = []
	for fName in dirL:
		fDir = os.path.join(dPath,fName)
		dirAbsPath.append(os.path.abspath(fDir))

	return dirAbsPath

def cFileName(ls,cStr,new=''):
	for fn in ls :
		n = os.path.basename(fn) #文件名与目录分开
		p = os.path.dirname(fn)
		newName = n.replace(cStr,new)
		newNamep = os.path.join(p,newName)
		os.rename(fn,newNamep)

ls = listAllDir('F:\All教程\第1部分：《妙味课堂JS基础篇》')
# for 1x in ls:
# 	print (x)
cFileName(ls,'妙味课堂原创JavaScript视频教程――')